//
//  DiscoveryViewController.m
//  YTT-IOS-CommonFramework
//
//  Created by aron on 2017/2/24.
//  Copyright © 2017年 aron. All rights reserved.
//

#import "DiscoveryViewController.h"
#import "BusinessInterface.h"

@interface DiscoveryViewController ()

@end

@implementation DiscoveryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"发现";

    // 注册Cell
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableViewCell class])];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - ......::::::: override :::::::......
static int count = 0;
- (void)requestDatasOnpage:(NSInteger)page refresh:(BOOL)refresh {
    
    // 测试网络数据请求
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (arc4random_uniform(10) > 0) {
            // 处理数据加载完成
            NSMutableArray* datas = [NSMutableArray array];
            for (int i = 0; i<GdefaultPageSize; i++) {
                [datas addObject:@(i*i)];
            }
            
            // 测试空数据
            if (count == 0) {
                [datas removeAllObjects];
                count ++;
            }
            
            [self handleDataLoadFailSuccess:datas refresh:refresh];
        } else {
            // 处理数据加载失败
            [self handleDataLoadFail];
        }
    });
}

@end
